package com.theme.passport.service.theme.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.theme.common.mvc.utils.PageUtils;
import com.theme.common.mvc.utils.Query;
import com.theme.passport.dao.theme.UserPayOrderDao;
import com.theme.passport.entity.theme.UserPayOrderEntity;
import com.theme.passport.service.theme.UserPayOrderService;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

import java.util.Map;


@Service("userPayOrderService")
public class UserPayOrderServiceImpl extends ServiceImpl<UserPayOrderDao, UserPayOrderEntity> implements UserPayOrderService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {

        String type = (String) params.get("type");
        String userId = (String) params.get("userId");
        IPage<UserPayOrderEntity> page = this.page(
                new Query<UserPayOrderEntity>().getPage(params),
                new QueryWrapper<UserPayOrderEntity>()
                        .eq(StringUtils.isNotBlank(type), "type", type)
                        .eq(StringUtils.isNotBlank(userId), "user_id", userId)
                        .orderByDesc("created")
        );

        return new PageUtils(page);

    }

    @Override
    public Long tradeCollectPrice(Map<String, Object> params) {
        return this.baseMapper.tradeCollectPrice(params);
    }

}